
***Plos ONE: Joy leads to overconfidence, and a simple countermeasure
*Main Experiment

*Type_4groups
1 = Control
2 = Joy treatment 
3 = Joy awareness
4 = Overconfidence awareness


*Test if date or time have an influence on oc and roc
an oc day session if Exclude == 0
an roc day session if Exclude == 0

*Descriptive results
tabstat age gender joyaw1 joyaw2 joyaw3 joyaw4 Profit if Exclude == 0, stat (mean semean min max)
tab gender if Exclude == 0

alpha gse1 gse2 gse3 gse4 gse5 gse6 gse7 gse8 gse9 gse10
alpha  opt1 opt4 opt10 opt3_rec opt7_rec opt9_rec 

tab Profit if Exclude == 0

*Overconfidence measures
gen p = no_rightQuiz / 10.
gen oc = con - p

gen rp = .
replace rp = 1 if no_rightQuiz > enemy_answers
replace rp = 0 if no_rightQuiz < enemy_answers
replace rp = 0.5 if no_rightQuiz == enemy_answers

gen roc = rcon - rp

*Performance tests
tabstat no_rightQuiz if Exclude == 0, stat (mean semean min max)
tab no_rightQuiz if Exclude == 0

anova p Type_4groups if Exclude == 0
effectsize Type_4groups
robvar p if Exclude == 0, by(Type_4groups)

*Figure 1.
tab oc if Exclude == 0
tab roc if Exclude == 0

*Correlations
pwcorr Treat_Control Treat_Joy Treat_JoyA Treat_OCA oc roc p part age gender employed Selfemployed Unemployed risks FExtraversion FEmotStab FConscientious FOpenness GSE OPT if Exclude == 0, sig star(.05)

*FIGURE 2 and 3
mean oc roc if Exclude == 0, over(Type_4groups) level(90)

gen Treat_JoyJoyA = .
replace Treat_JoyJoyA = 1 if Treat_Joy == 1
replace Treat_JoyJoyA = 0 if Treat_JoyA == 1

gen Treat_JoyControl = .
replace Treat_JoyControl = 1 if Treat_Joy == 1
replace Treat_JoyControl = 0 if Treat_Control == 1
ttest oc if Exclude == 0, by(Treat_JoyJoyA)

ttest oc if Exclude == 0, by(Treat_JoyJoyA)
ttest oc if Exclude == 0, by(Treat_JoyControl)
ttest oc == 0 if Exclude == 0 & Treat_Joy

ttest roc if Exclude == 0, by(Treat_JoyJoyA)
ttest roc if Exclude == 0, by(Treat_JoyControl)
ttest roc == 0 if Exclude == 0 & Treat_Joy


***Table 3
anova oc Type_4groups if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova oc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova oc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova oc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness c.p if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova oc Type_4groups c.p if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv


anova roc Type_4groups if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova roc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova roc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova roc Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness c.p if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv

anova roc Type_4groups c.p if Exclude == 0
effectsize Type_4groups
pwcompare i.Type_4groups, pv


* Test if gender had a moderating effect
gen sex_Type = gender*Type_4groups
an oc Type_4groups gender sex_Type if Exclude == 0
an roc Type_4groups gender sex_Type if Exclude == 0

* Ologit regressions
** Reference group is control
ologit oc Treat_Joy Treat_JoyA Treat_OCA if Exclude == 0
ologit roc Treat_Joy Treat_JoyA Treat_OCA if Exclude == 0

ologit oc Treat_Joy Treat_JoyA Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness if Exclude == 0
ologit roc Treat_Joy Treat_JoyA Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness if Exclude == 0

ologit oc Treat_Joy Treat_JoyA Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness p if Exclude == 0
ologit roc Treat_Joy Treat_JoyA Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness p if Exclude == 0

** Reference group is Joy Awareness
ologit oc Treat_Control Treat_Joy Treat_OCA if Exclude == 0
ologit roc Treat_Control Treat_Joy Treat_OCA if Exclude == 0

ologit oc Treat_Control Treat_Joy Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness if Exclude == 0
ologit roc Treat_Control Treat_Joy Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness if Exclude == 0

ologit oc Treat_Control Treat_Joy Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness p if Exclude == 0
ologit roc Treat_Control Treat_Joy Treat_OCA gender age age2 employed Selfemployed part GSE risks OPT Extraversion Agreeableness Conscientiousness EmotionalStability Openness p if Exclude == 0


* Kruskal Wallis test with Dunn's posthoc test
kwallis oc, by(Type_4groups)
kwallis roc, by(Type_4groups)

dunntest oc, by(Type_4groups)
dunntest roc, by(Type_4groups)


* Relative overconfidence based on random opponent matching
gen rp_r1 = .
replace rp_r1 = 1 if no_rightQuiz > enemy_answers1
replace rp_r1 = 0 if no_rightQuiz < enemy_answers1
replace rp_r1 = 0.5 if no_rightQuiz == enemy_answers1

gen rp_r2 = .
replace rp_r2 = 1 if no_rightQuiz > enemy_answers2
replace rp_r2 = 0 if no_rightQuiz < enemy_answers2
replace rp_r2 = 0.5 if no_rightQuiz == enemy_answers2

gen rp_r3 = .
replace rp_r3 = 1 if no_rightQuiz > enemy_answers3
replace rp_r3 = 0 if no_rightQuiz < enemy_answers3
replace rp_r3 = 0.5 if no_rightQuiz == enemy_answers3

gen rp_r4 = .
replace rp_r4 = 1 if no_rightQuiz > enemy_answers4
replace rp_r4 = 0 if no_rightQuiz < enemy_answers4
replace rp_r4 = 0.5 if no_rightQuiz == enemy_answers4

gen rp_r5 = .
replace rp_r5 = 1 if no_rightQuiz > enemy_answers5
replace rp_r5 = 0 if no_rightQuiz < enemy_answers5
replace rp_r5 = 0.5 if no_rightQuiz == enemy_answers5

gen rp_r6 = .
replace rp_r6 = 1 if no_rightQuiz > enemy_answers6
replace rp_r6 = 0 if no_rightQuiz < enemy_answers6
replace rp_r6 = 0.5 if no_rightQuiz == enemy_answers6

gen rp_r7 = .
replace rp_r7 = 1 if no_rightQuiz > enemy_answers7
replace rp_r7 = 0 if no_rightQuiz < enemy_answers7
replace rp_r7 = 0.5 if no_rightQuiz == enemy_answers7

gen rp_r8 = .
replace rp_r8 = 1 if no_rightQuiz > enemy_answers8
replace rp_r8 = 0 if no_rightQuiz < enemy_answers8
replace rp_r8 = 0.5 if no_rightQuiz == enemy_answers8

gen rp_r9 = .
replace rp_r9 = 1 if no_rightQuiz > enemy_answers9
replace rp_r9 = 0 if no_rightQuiz < enemy_answers9
replace rp_r9 = 0.5 if no_rightQuiz == enemy_answers9

gen rp_r10 = .
replace rp_r10 = 1 if no_rightQuiz > enemy_answers10
replace rp_r10 = 0 if no_rightQuiz < enemy_answers10
replace rp_r10 = 0.5 if no_rightQuiz == enemy_answers10

*Relative overconfidence roc is computed analogously to oc.
gen roc_r1 = rcon - rp_r1
gen roc_r2 = rcon - rp_r2
gen roc_r3 = rcon - rp_r3
gen roc_r4 = rcon - rp_r4
gen roc_r5 = rcon - rp_r5
gen roc_r6 = rcon - rp_r6
gen roc_r7 = rcon - rp_r7
gen roc_r8 = rcon - rp_r8
gen roc_r9 = rcon - rp_r9
gen roc_r10 = rcon - rp_r10


*Table 4
an roc_r1 Type_4groups if Exclude == 0
pwcompare i.Type_4groups, pv
effectsize Type_4groups

an roc_r1 Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part if Exclude == 0
pwcompare i.Type_4groups, pv
effectsize Type_4groups

an roc_r1 Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness if Exclude == 0
pwcompare i.Type_4groups, pv
effectsize Type_4groups

an roc_r1 Type_4groups c.gender c.age c.age2 c.employed c.Selfemployed c.Unemployed c.part c.GSE c.risks c.OPT c.FExtraversion c.FEmotStab c.FConscientious c.FOpenness c.p if Exclude == 0
pwcompare i.Type_4groups, pv
effectsize Type_4groups

an roc_r1 Type_4groups c.p if Exclude == 0
pwcompare i.Type_4groups, pv
effectsize Type_4groups


mean roc_r1 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r2 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r3 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r4 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r5 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r6 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r7 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r8 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r9 if Exclude == 0, over(Type_4groups) level(90)
mean roc_r10 if Exclude == 0, over(Type_4groups) level(90)


an roc_r1 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r2 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r3 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r4 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r5 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r6 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r7 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r8 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r9 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv

an roc_r10 Type_4groups if Exclude == 0
regress
pwcompare i.Type_4groups, pv


regress roc_r1 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r2 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r3 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r4 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r5 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r6 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r7 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r8 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r9 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
regress roc_r10 Treat_Control Treat_Joy Treat_OCA if Exclude == 0
